import { createRouter, createWebHistory } from 'vue-router'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      redirect: '/articles'
    },
    {
      path: '/articles',
      name: 'articles',
      component: () => import('@/views/Article/ArticleList.vue'),
    },
    {
      path: '/article/:id',
      name: 'article',
      component: () => import('@/views/Article/ArticleDetail.vue'),
      props: true
    },
    {
      path: '/article/:id/edit',
      name: 'articleEdit',
      component: () => import('@/views/Article/ArticleEdit.vue'),
      props: true
    },
    {
      path: '/article/new',
      name: 'articleNew',
      component: () => import('@/views/Article/ArticleEdit.vue'),
      props: { id: '-1' }
    }
  ]
})

export default router
